package com.geese.common;

/**
 * Created by Z先生 on 2017/2/23.
 */
public class MyResult<T> {

    private int code;
    private String msg;
    private T result;

    public static MyResult success() {
        return success(null);
    }

    public static MyResult success(Object detail) {
        MyResult myResult = new MyResult();
        myResult.setCode(200);
        myResult.setMsg("success");
        myResult.setResult(detail);
        return myResult;
    }

    public static MyResult error() {
        return error(null);
    }

    public static MyResult error(String description) {
        return error(ErrorInfo.CODE_IP_REFUSED, description);
    }

    public static MyResult error(int code, String description) {
        MyResult myResult = new MyResult();
        myResult.setCode(code);
        myResult.setMsg(description);
        myResult.setResult(null);
        return myResult;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }
}
